package com.kyzh.core.pager.weal.rank

import android.os.Bundle
import androidx.viewpager.widget.ViewPager
import com.gushenge.core.base.activity.BaseActivity
import com.kyzh.core.R
import com.kyzh.core.adapters.RankTopAdapter
import kotlinx.android.synthetic.main.activity_rank.*
import org.jetbrains.anko.backgroundResource

class RankActivity : BaseActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_rank)
        initView()
    }

    private fun initView() {

        viewpager.adapter = RankTopAdapter(this@RankActivity, arrayListOf(getString(R.string.hotGameRank), getString(R.string.newGameRank)))
        topTab.setupWithViewPager(viewpager)
        viewpager.currentItem = 0
        viewpager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
            override fun onPageScrollStateChanged(state: Int) {

            }

            override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {

            }

            override fun onPageSelected(position: Int) {
                if (position == 0) {
                    appbar.backgroundResource = R.drawable.ranking_bg1
                    rankTitle.text = getString(R.string.hotgameTop)
                    rankContent.text = getString(R.string.hotgameTop1)
                } else {
                    appbar.backgroundResource = R.drawable.ranking_bg2
                    rankTitle.text = getString(R.string.newGameExpectation)
                    rankContent.text = getString(R.string.newGameExpectation1)
                }
            }
        })
    }
}
